﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TSqlServer;

/// <summary>
/// TCMSPiece 的摘要说明
/// </summary>
public class TCMSPiece : TData
{
    //常量
    const string CTableName = "t_cms_piece";
    const string CKeyName = "uid";
    //与数据表字段对应的变量
    private string FUID;
    private string FPieceName;
    private string FPieceContent;
    private int FStatus;
    private DateTime FInTime;
    private string FInMan;
    private int FIId;

    public TCMSPiece()
    {
        FTableName = CTableName;
        FKeyName = CKeyName;
    }

    public TCMSPiece(string sID)
    {
        FTableName = CTableName;
        FKeyName = CKeyName;
        FKeyValue = sID;
    }

    //根据UID获得记录值
    public override void Select()
    {
        string strSql = GetSelectString();
        TSqlDB oDB = new TSqlDB(strSql);
        if (!oDB.EOF)
        {
            FUID = oDB["uid"].ToString();
            FPieceName = oDB["piecename"].ToString();
            FPieceContent = oDB["piececontent"].ToString();
            FStatus = oDB["status"].ToInt();
            FInTime = oDB["intime"].ToDateTime();
            FInMan = oDB["inman"].ToString();
            FIId = oDB["iid"].ToInt();
        }
        oDB.Free();
    }

    //插入新记录。
    public void Insert()
    {
        string ExSql = "newid(),'" + FPieceName + "','" + FPieceContent + "',";
        ExSql += "0,getdate(),'" + FInMan + "'";
        base.Insert(ExSql);
    }
    //更新记录。
    public void Update()
    {
        string ExSql = "piecename='" + FPieceName + "',piececontent='" + FPieceContent + "',";
        ExSql += "intime=getdate()";
        base.Update(ExSql);
    }

    //更新记录,改变状态，放入回收站。0=正常，9=回收站
    public void Update_status()
    {
        string ExSql = "status=" + FStatus.ToString(); ;
        base.Update(ExSql);
    }

    //静态，可以不用创建对象即可调用。
    public static void DeleteByID(string sID)
    {
        TData.DeleteByID(sID, CTableName, CKeyName);
    }

    public string UID
    {
        get
        {
            return FUID;
        }
        set
        {
            FUID = value;
        }
    }

    public string PieceName
    {
        get
        {
            return FPieceName;
        }
        set
        {
            FPieceName = value;
        }
    }

    public string PieceContent
    {
        get
        {
            return FPieceContent;
        }
        set
        {
            FPieceContent = value;
        }
    }

    public int Status
    {
        get
        {
            return FStatus;
        }
        set
        {
            FStatus = value;
        }
    }

    public string InMan
    {
        get
        {
            return FInMan;
        }
        set
        {
            FInMan = value;
        }
    }

    public DateTime InTime
    {
        get
        {
            return FInTime;
        }
        set
        {
            FInTime = value;
        }
    }

    public int IId
    {
        get
        {
            return FIId;
        }
        set
        {
            FIId = value;
        }
    }
}
